<?php
/**
 * RUBIK IT Solution & Development ltd.
 *
 * PROJECT		: Rubik Ultimate
 * @version 	: 1.1
 * COPYRIGHT	: 2008
 * ------------------------------------------------------
 * 
 * [GENERAL INFO OF THIS FILE] 
 *
 * @author			hoadn <hoadn@rubik.com.vn>
 * @package		 	core.html.filedInfo
 *
 * Created on	:Sep 19, 2008
 */

// no direct access
defined ( '_FW_EXEC' ) or die ( 'Restricted access' );

RCoreImporter::cls('html.fieldInfo.BasicFileHtmlFieldInfo');

class FlashVideoHtmlFieldInfo extends BasicFileHtmlFieldInfo {
	
	var $_width = null;
	var $_height = null;
	
	/**
	 * Set the size of flash view
	 *
	 * @param int $width
	 * @param int $height
	 */
	function setSize($width, $height) {
		$this->_width = $width;
		$this->_height = $height;
	}
	
	/**
	 * Function for geting the html for previewing data
	 *
	 * @return string
	 */
	function buildHtmlPreviewData($extAttributes = '', $key=null, $dataType ='S') {
		$downloadLink = $this->getDownloadableLink();
		if ($downloadLink == '#') {
			$noFileMsg = SysLanguage::_('No file');
			return '<div style="text-align:center;">'.$noFileMsg.'</div>';
		}
		
		$this->_setDefaultSizeIfNull(200, 100);
		$swfFile = 'player.swf';
		$flashVar = 'file='.$this->getDownloadableLink().'&bgcolor1=189ca8&bgcolor2=085c68';
		
		$swfFile	= SYS_ROOT_URL."libraries/player/video/{$swfFile}";
		return RHtmlHelper::createFlashObject($swfFile, $this->_width, $this->_height, 'js', array('FlashVars'=>$flashVar, 'bgcolor'=>'000000'));
	}
	
	function _setDefaultSizeIfNull($width, $height) {
		if (!$this->_width) {
			$this->_width = $width;
		}

		if (!$this->_height) {
			$this->_height = $height;
		}
	}
	
	/**
	 * Function for geting the html for inputing data
	 *
	 * @abstract 
	 * @return string
	 */
	function getHtmlInputData($dataType = '', $extAttribute = '') {
		$html = parent::getHtmlInputData($dataType, $extAttribute);
		$removeName = "ctrl_rm_".$this->_fieldName;
		$removeText = SysLanguage::_('Remove this field');
		$preview = $this->buildHtmlPreviewData($extAttribute);
		$html = "<div>{$html}</div><div style=\"float:left; padding-right: 10px;\"><input type=\"checkbox\" value=\"1\" name=\"{$removeName}\" id=\"{$removeName}\" style=\"width: 30px;\"/><label for=\"{$removeName}\">{$removeText}</label></div>
					<div>{$preview}</div><div style=\"clear:both;\" />";
		return $html;
	}
	
}
?>